@extends('client/layoutIndex')
@section('title')

@stop
@section('link')
	<link rel="stylesheet" href="{{ asset('client/css/type.css') }}">
@stop
@section('content')
	<!-- --最新兑换-- -->
	
		{{--<div class="zuixin">--}}
			
				<div class="tit">
					<span id="msg" style="display: none;">
						@if (count($errors) > 0)
							@foreach ($errors->all() as $error)
								<div style="width: 100%;">
									<span style="color: red;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ $error }}</span>
								</div>
							@endforeach
						@endif
					</span>
					<script type="text/javascript">
						var _msg = $('#msg div span').text();
						console.log(_msg);
						if(_msg != ''){
							layer.msg(_msg);
						}
					</script>
				</div>
			
		{{--</div>--}}
	<!-- --最新兑换 end-- -->
	<!-- --兑换中心-- -->
	<div class="xq">
		<div class="xq-center">
			<div class="ggw">
				<div class="ggw7"><img src="{{ asset('productImg/'.$ad4->picture) }}" width="180px" height="200px"></div>
				<div class="ggw8"><img src="{{ asset('productImg/'.$ad5->picture) }}" width="180px" height="200px"></div>
			</div>
			<div class="dhzx">
				<form class="form-horizontal" action="{{ url('client/toCart') }}" method="post">
					{{csrf_field()}}
					<div class="ts-dh">
						<h3 style="font-weight:bold;text-align:left;">兑换商品</h3>
						<span></span>
						<img src="{{ asset('client/image/xvxian.png') }}" class="img-responsive">
					</div>
					{{--<div class="dhzx-tit">--}}
						{{--<h2>兑换中心</h2>--}}
					{{--</div>--}}
					<div class="dhzx-xq">
						<div class="dhzx-xq-top">
							<div class="dhzx-xq-top-left">
								<!-- <div style="width:100%;height:80px;text-align:center;line-height:80px;">
                                    <span style="font-size:20px;font-weight:bold;">尊敬的用户：</span>
                                    <span style="font-size:20px;font-weight:bold;color:#fb5903">用户名</span>
                                </div> -->
								<div style="width:100%;height:200px;text-align:center;margin-top:40px;">
									<img src="{{ asset('productImg/'.$list->goods_picture) }}" width="270px">
								</div>
							</div>
							<div class="dhzx-xq-top-right">
								<input type="hidden" name="id" value="{{ $list->id }}">
								<!-- <div style="width:100%;height:80px;text-align:left;line-height:80px;">
                                    <span style="font-size:20px;font-weight:bold;">您当前可用的积分：</span>
                                    <span style="font-size:20px;font-weight:bold;color:#fb5903">1000</span>
                                </div> -->
								<div style="width:100%;height:80px;text-align:left;line-height:80px;">
									<span style="font-size:18px;font-weight:bold;">商品名称：</span>
									<span style="font-size:18px;font-weight:bold;">{{ $list->goods_name }}</span>
								</div>
								<div style="width:100%;height:80px;text-align:left;line-height:80px;">
									<div style="float:left;height:80px;">
										<span style="font-size:18px;font-weight:bold;">商品积分：</span>
										<span>折后</span>
										<span style="font-size:20px;">{{ ($list->goods_price) }}</span>
										<span style="font-size:30px;font-weight:bold;">/</span>
									</div>
									<div style="float:left;height:80px;">
										<span style="line-height:100px;">原价<s style="font-size:15px;">{{ round($list->goods_price/0.85)}}</s></span>
									</div>
									
									
								</div>
								<div style="width:100%;height:80px;text-align:left;line-height:80px;">
									<span style="font-size:18px;font-weight:bold;">商品库存：</span>
									<span style="font-size:18px;font-weight:bold;">{{ $list->goods_inventory }}
										<input type="hidden" value="{{ $list->goods_inventory }}" id="inventory">
										</span>
									<span style="font-size:18px;font-weight:bold;">件</span>
								</div>
								<div style="width:100%;height:80px;text-align:left;line-height:80px;">
									<span style="font-size:18px;font-weight:bold;">商品数量：</span>
									<a class="btn btn-default btn-sm" id="min" onclick="min1()">-</a>
									<span><input type="text" name="number" id="num" value="1" style="width:60px;height:30px;line-height:30px;text-align:center;"></span>
									<a class="btn btn-default btn-sm" id="max" onclick="max1()">+</a>
									<span style="font-size:18px;font-weight:bold;">件</span>
								</div>
							</div>
						</div>
						<div class="dhzx-xq-bottom">
							<center>
							<div style="width:50%;margin-top:50px;float:left;text-align:right;">
								<a href="{{ url('client/toOrder/'.$list->id) }}" id="d" class="btn btn-danger btn-lg">立即兑换</a>
							</div>
							<script>
								var num = document.getElementById('num').value;
								var h = document.getElementById("d").getAttribute("href") +"/" + num;
								document.getElementById("d").setAttribute("href",h);
							</script>
							<div style="width:50%;margin-top:50px;float:left;">
								<button type="submit" class="btn btn-danger btn-lg">加入购物车</button>
							</div>
						</center>
						</div>
					</div>
				</form>
			</div>
			<div class="ggw-1">
				<div class="ggw9"><img src="{{ asset('productImg/'.$ad6->picture) }}" width="239px" height="310px"></div>
			</div>
		</div>
	</div>
	<!-- --兑换中心 end-- -->
	<!-- --商品说明-- -->
	<div class="spsm">
		<div class="spsm-center">
			<div >
				<h3 style="font-size:20px;font-weight:bold;text-align:left;position: absolute;top: 1010px">商品说明</h3>
				<img src="{{ asset('client/image/xvxian.png') }}" class="img-responsive" style="position: absolute;top: 1060px">
			</div>
			<div style="width:100%;height:60px;line-height:60px;margin-left:20px;">
				<span style="font-weight:bold;font-size:18px;position: absolute;top: 1050px">商品描述</span>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<span style="position: absolute;top: 1070px">{{ $list->goods_introduce }}</span>
			</div>
		</div>
	</div>
	<script>
		var inventory=document.getElementById("inventory");
		var min=document.getElementById("min");
		var num=document.getElementById("num");
		var max=document.getElementById("max");

		function min1(){
			if(num.value<=1){
				num.innerHTML=1;
			}else{
				num.value-=1;
				num.innerHTML=num.value;
			}
		}
		function max1(){
			var num1 =parseInt(num.value);
			var inventory1=inventory.value;
			if(num1 >= inventory1){
				num.value=inventory1;
				alert("只有这么多啦！");
			}
			else{
				num.value=num1+1;
			}
		}
	</script>
@stop

